package com.itqf.utils;

import java.util.HashMap;

/**
 * @Description:
 * @Company: 千锋互联
 * @Author: 李丽婷
 * @Date: 2020/11/17
 * @Time: 上午10:22
 */
public class R  extends HashMap {//result   response
    private int code;//状态码  至少两个状态  例如：0:代表成功    1：代表失败
    private String msg;//操作后的信息

    public  R(){}

    public  R(int code){
        super.put("code",code); //{"code":0}
    }
    public  R(int code,String msg){
        super.put("code",code);
        super.put("msg",msg);
    }

    public  static  R  ok(){

        return  new R(0);//操作成功
    }
    public  static  R  ok(String  msg){

        return  new R(0,msg);//操作成功
    }

    public  static  R  error(){

        return  new R(1);//操作失败
    }
    public  static  R  error(String  msg){

        return  new R(1,msg);//操作失败
    }

    public  R  put(String key,Object value){
         super.put(key,value);

         return  this;
    }


}
